var tab = document.querySelector('.tobBox').querySelectorAll('li');


for (var i = 0; i < tab.length; i++) {

  tab[i].onclick = function () {
    for (var i = 0; i < tab.length; i++) {
      tab[i].className = '';
    }
    this.className = 'active';

  }

}


const List = document.querySelectorAll('.data')

console.log(List)
var val;

Data.forEach((item, index) => {
  // console.log(item);
  val += ' <li><div class="icon"> <img src="' + item.icon + '" alt="" />  </div> <div class="text">' + item.val + '</div></li>'


  // List[0].innerHTML = val
})

val = val.slice(9)
console.log(val);
List[0].innerHTML = val


// 返回顶部
const returnTop = document.querySelector('.returntop')

returnTop.addEventListener('click', function () {

  // 添加动画 由快到慢
  scrollToptimer = setInterval(function () {
    console.log("定时循环回到顶部")
    var top = document.body.scrollTop || document.documentElement.scrollTop;
    var speed = top / 4;
    if (document.body.scrollTop != 0) {
      document.body.scrollTop -= speed;
    } else {
      document.documentElement.scrollTop -= speed;
    }
    if (top == 0) {
      clearInterval(scrollToptimer);
    }
  }, 30)
})
